// 翻滚加载(热搜部分)
// 思路;向下翻滚，页数加一，请求发送一次，渲染一次
var currentPage = 1;
// 判断数据是否为0
var url;

function getrestMsg() {
  $(window).scroll(function () {
    if (
      Math.round($(window).scrollTop() + $(window).height()) ==
      $(document).height()
    ) {
      currentPage++;
      // 滚动次数

      $.ajax({
        url: `/weibo/my/toMyLoadedIdols?pageNo=${currentPage}&pageSize=10`,
        type: "get",
        data: {},
        success: function (result) {
          let allnews = document.querySelector("#news");
          let ul = allnews.querySelector("ul");
          let focusList = allnews.querySelector(".focusList");
          let nomore = focusList.querySelector(".nomore");
          console.log(result);
          // 渲染

          for (let i = 0; i < result.length; i++) {
            //   判断是赞评论还是赞文章
            let user = result[i];

            ul.innerHTML += `
              <li class="focusLi"  uid="${user.id}">
              <div class="headPhoto">
                <img
                  
                  src=${user.avatarUrl}"
                  alt="用户头像"
                />
              </div>
              <div class="userInfoli">
                <div class="user-msg">
                  <p  class="userName">${user.username}</p>
                  <p  class="userLabel">${user.label}</p>
                </div>
              </div>
              <div>
                <button class="followBtn al-attention" onclick="personAttention(this)" uid="${user.id}">
                  <i class="iconfont">&#xe664;</i>已关注
                </button>
              </div>
            </li>
                  `;
          }

          if (result.length >= 0 && result.length < 10) {
            nomore.classList.remove("hidden");
          }
        },
      });
    }
  });
}
getrestMsg();
